<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>影院报表</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/report/agentReport?cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/report/agentReport?cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 45
        });
    });

    function getRowData(value, rec) {
        var id = rec.id;
    }

    function check() {
        $("#startTime").val($("#sstartTime").datebox("getValue"));
        $("#endTime").val($("#sendTime").datebox("getValue"));

    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
       BACKGROUND="${pageContext.request.contextPath }/images/maintitle.jpg" class="tablelist2">
    <form action="${pageContext.request.contextPath }/report/agentReport" method="post" onsubmit="check();">
        <input type="hidden" name="startTime" id="startTime"/>
        <input type="hidden" name="endTime" id="endTime"/>
        <tr class="tableselect2">
            <td align="left">
                <div class="tools">
                    <ul class="toolbar">
                    </ul>
                </div>
            </td>
            <td align="right">
                影院
                <select name="agentId" id="agentId" style="width:150px">
                    <option value="0">请选择</option>
                    <c:forEach items="${agentList}" var="v">
                        <c:if test="${plan.agentId == v.agentId}">
                            <option value="${v.agentId}" selected>${v.agentName}</option>
                        </c:if>
                        <c:if test="${plan.agentId != v.agentId}">
                            <option value="${v.agentId}">${v.agentName}</option>
                        </c:if>
                    </c:forEach>
                </select>
                <input type="text" name="agentName" id="agentName" style="width:100px"
                       onchange="changeAgent(this.value);">
                日期
                <input type="text" class="easyui-datebox" name="sstartTime" id="sstartTime" value="${plan.startTime}"
                       style="width: 120px"/>
                <input type="text" class="easyui-datebox" name="sendTime" id="sendTime" value="${plan.endTime}"
                       style="width: 120px"/>
                <input type="submit" value="查询">
            </td>
        </tr>
    </form>
</table>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px">
    <thead>
    <tr>
        <th field="id" width=150>序号</th>
        <th field="agentName" width=200 align="center">影院名称</th>
        <th field="salePrice" width=200 align="center">票房金额</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" var="v" varStatus="st">
        <tr>
            <td>${st.index+1 }</td>
            <td>${v.agentName }</td>
            <td>${v.salePrice }</td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
<script type="text/javascript">
    var orgjson = {"data": []};

    function initAgentJson() {
        $("#agentId option").each(function () {
            var item = {"value": this.value, "text": this.text};
            orgjson.data.push(item);
        });
    }

    initAgentJson();

    function changeMovie(value) {
        $("#agentId").empty();
        $.each(orgjson.data, function (i, item) {
            if (item["text"].indexOf(value) >= 0) {
                $("#agentId").append("<option value='" + item["value"] + "'>" + item["text"] + "</option>");
            }
        });
    }
</script>
</html>